
#include	"SysConfig.h"
#include	"Define.h"
#include	"Function.h"

#include	"Tuner.h"
#include	"Display.h"
#include	"Audio.h"
#include	"UI_Main.h"
#include	"Power.h"
#include	"Model_Option.h"
#ifdef  ST7565P
#include	"ST7565P.h"
#endif
#ifdef  CD
#include    "CD_MECHA.h"
#endif

#ifdef  LC786XXX
#include	"LC786XXX.h"
#endif

#ifdef BLUETOOTH
#include	"Bluetooth.h"
#include	"Movon.h"
#endif
#ifdef  PHONE_BOOK
#include	"PhoneBook.h"
#endif

#ifdef  MIC
#include	"MIC.h"
#endif
#ifdef  AUTO_GUIDE
#include	"AutoGuide.h"
#endif
#ifdef  AV_CONTROLLER
#include	"AVController.h"
#endif
extern LC786X_MEDIA_ID  ucLC786XXX_CurrentMediaID;
extern unsigned char ucLC786XXX_SequencerVersion[4];
UI_DISP ucDISP_TempDispMode;
unsigned char ucDISP_TempPage;
unsigned char usDISP_TempDispMode_Timer50msec;
unsigned char ucDISP_Blink_Timer50msec;
unsigned char ucDISP_Blink;
unsigned char ucDISP_ScrollEnable;

unsigned char ucDISP_ClockMode;
unsigned char ucDISP_CurrentDisplay_Timer50msec;

unsigned char ucDISP_Buf[12];
unsigned long ulDISP_IconBuf;

unsigned char ucDISP_RadioInfo_Active;
unsigned char ucDISP_FolderName;
unsigned char ucDISP_FileName;
unsigned char ucDISP_FolderName_Timer50msec;
unsigned char ucDISP_FileName_Timer50msec;

#ifdef  DOT_SCROLL
unsigned short usDISP_DotScroll_Timer5msec;
#endif

#ifdef  BLUETOOTH
unsigned char ucDISP_BluetoothName[BT_DEVICE_NAME_LENGTH];
extern BT_PROC ucBT_Process;
extern unsigned char ucPBAP_SearchResult;
extern PBAP_LIST	sPBAP_List;
extern unsigned char ucDISP_BT_CallerID[BT_CALLERID_LEN];
extern unsigned char ucDISP_PBAPSearchResult;
extern unsigned char ucMV_HF_AudioStatus_Timer50msec;
#endif

#ifdef CD
unsigned char ucDISP_CD_ICON_Step;
unsigned char ucDISP_CD_ICON_Timer5msec;
#endif 
extern unsigned char ucLC786XXX_UpdatePersent;
extern unsigned char ucDisp_TempDisplay_MuteActive;

extern unsigned char ucRTC_Hour;
extern unsigned char ucRTC_Min;
extern unsigned char ucRTC_Sec;

extern unsigned char ucAUDIO_Volume;
extern unsigned char ucAUDIO_Mute;
extern unsigned char ucAUDIO_TelMute;

extern UI_EQ_MODE ucAUDIO_Equalizer;
extern unsigned char ucAUDIO_Loud;

extern unsigned char ucAUX_Detected;

extern UI_MENU_ID ucMenuID;
extern unsigned char ucMENU_SetHour;

extern unsigned char ucDECK_Mode;

extern UI_TUNER_MODE	ucTuner_Mode;
extern unsigned char ucLC786XXX_UpdatePersent;
extern unsigned char DRV_LC786XXX_FirmwareUpdate_ON;
extern unsigned char ucLC786XXX_UpdateStatus;

#ifdef BLUETOOTH
extern unsigned char ucBT_Function_Active;
extern BT_DEVICE	sBT_BDList[BT_DEVICE_NUM];
extern unsigned char ucBT_Volume;
extern MV_CALL_STATUS ucMV_CallStatus;
extern unsigned char BT_ConnectStatus(void);
extern unsigned char *BT_GetConnectedDeviceName(void);
extern unsigned char BT_CurrentProcess_Connect(void);
#endif
#ifdef  PHONE_BOOK
extern MV_PB_STATUS ucMV_PBAP_Status;
extern unsigned char ucPBAP_CurrentContents;
#endif

extern void TUNER_DISP_MainText(void);
extern void TUNER_DISP_IconMain(void);
extern void TUNER_DISP_SubText(void);
extern unsigned char TUNER_CurrentBandType(void);

extern void USB_DISP_MainText(void);
extern void USB_DISP_IconMain(void);
extern void USB_DISP_SubText(void);
extern unsigned char	ucUSB_ErrorCode;

extern void AUX_DISP_MainText(void);
extern void AUX_DISP_IconMain(void);
extern void AUX_DISP_SubText(void);

extern void BTH_DISP_MainText(void);
extern void Bluetooth_DISP_IconMain(void);
extern void Bluetooth_DISP_Display_SubText(void);
extern void BTA_DISP_SubText(void);
extern void BTA_DISP_MainText(void);
extern void BTA_DISP_IconMain(void);
extern unsigned short DRV_LC786XXX_BCDToHex(unsigned short ucBcd);

#ifdef  FILE_SEARCH
extern unsigned char USB_DISP_FileSearch(void);
#ifdef  CD
extern unsigned char CD_DISP_FileSearch(void);
#endif
#endif

#ifdef CD
extern void CD_DISP_Display_SubText(void);
extern void CD_DISP_MainText(void);
extern void CD_DISP_IconMain(void);
extern unsigned char CD_GetStatusFlag(unsigned char ucDes);
extern unsigned char ucDECK_Disc;
extern unsigned char ucCD_ErrorCode;
#endif

#ifdef LC786XXX
extern unsigned char ucLC786XXX_USB_Detected;
#endif

extern unsigned char MENU_DISP_Main(void);
extern void UI_DMENU_ClockSet_AM_PM(unsigned char ucHour);
#ifdef  MODEL_ARA5040
extern void PT6524_MakeDriverData(unsigned char *ucFontBuf, unsigned short *ucIconBuf);
#endif

extern UI_FUNCTION	FUNC_GetCurrentFunction(void);
#ifdef  ATOMIC
extern unsigned char ATOMIC_FM_GetSeekStopLevel(void);
extern unsigned char ATOMIC_AM_GetSeekStopLevel(void);
extern unsigned char ATOMIC_GetSignalLevel(void);
extern unsigned char ATOMIC_GetMultiPath(void);
extern unsigned char ATOMIC_GetUltraSonicNoise(void);
extern unsigned char ATOMIC_GetStereoBlend(void);
#endif
#ifdef  HERO
extern unsigned char HERO_FM_GetSeekStopLevel(void);
extern unsigned char HERO_AM_GetSeekStopLevel(void);
extern unsigned char HERO_GetSignalLevel(void);
extern unsigned char HERO_GetMultiPath(void);
extern unsigned char HERO_GetUltraSonicNoise(void);
extern unsigned char HERO_GetStereoBlend(void);
#endif

unsigned char DISP_TunerInfoDisplay(void)
{
	if  (ucDISP_RadioInfo_Active == 0x00)
	{
		return(0);
	}
	return(1);
}

void DISP_IconSetStatusFlag(unsigned char ucDes, unsigned long ulFlag)
{
	if  (ucDes == 1)
	{
		ulDISP_IconBuf = ulDISP_IconBuf | ulFlag;
	}
	if  (ucDes == 0)
	{
		ulDISP_IconBuf = ulDISP_IconBuf & (~ulFlag);
	}
}

void DISP_IconClearStatusFlag(void)
{
	ulDISP_IconBuf = 0x00000000;
}

void DISP_SetCurrentDisplay(void)
{
	ucDISP_CurrentDisplay_Timer50msec = 5000/100;
	ucDISP_TempPage = 0;
}

unsigned char DISP_BluetoothTestMode(void)
{
	unsigned char ucDes;

	ucDes = 0;
	switch  (ucDISP_TempDispMode)
	{		
		case DISP_BT_TEST:
		case DISP_BT_ADD1:
		case DISP_BT_ADD2:
		case DISP_BT_MIC:
		case DISP_BT_DUT:
			ucDes = 1;
			break;
	}

	return(ucDes);
}

void DISP_ClockDisplayModeCtrl(void)
{
	if  (ucDISP_ClockMode == 1)
	{
		ucDISP_ClockMode = 0;
	}
	else
	{
		ucDISP_ClockMode = 1;
		ucDISP_FileName = 0;
		ucDISP_FolderName = 0;
	}
	ucDISP_CurrentDisplay_Timer50msec = 0;
}

void DISP_SetBlink(void)
{
	ucDISP_Blink = 0;
	ucDISP_Blink_Timer50msec = 500/50;
}

void DISP_SetTempDisplayMode(UI_DISP ucDes)
{
	if  (PRW_AskACCStatusIdle() == 1)
	{
		return;
	}
	usDISP_TempDispMode_Timer50msec = 3000/50;
	ucDISP_TempDispMode = ucDes;
	DISP_SetBlink();
}

unsigned char DISP_BufferNull(unsigned char *ucBuf, unsigned char ucSize)
{
	unsigned char i;

	for(i == (ucSize - 1); i != 0;--i)
	{
		if  ((*(ucBuf + i) == 0x00) || (*(ucBuf + i) == ' '))
		{
		}
		else
		{
			break;
		}
	}

	return(i);
}

void DISP_SetTempDisplayMode_10Sec(UI_DISP ucDes)
{
	if  (PRW_AskACCStatusIdle() == 1)
	{
		return;
	}
	usDISP_TempDispMode_Timer50msec = 10000/50;
	ucDISP_TempDispMode = ucDes;
	DISP_SetBlink();
}
void DISP_SetTempDisplayMode_3Sec(UI_DISP ucDes)
{
	if  (PRW_AskACCStatusIdle() == 1)
	{
		return;
	}
	usDISP_TempDispMode_Timer50msec = 3000/50;
	ucDISP_TempDispMode = ucDes;
	DISP_SetBlink();
}
void DISP_SetTempDisplayMode_6Sec(UI_DISP ucDes)
{
	if  (PRW_AskACCStatusIdle() == 1)
	{
		return;
	}
	usDISP_TempDispMode_Timer50msec = 5000/50;
	ucDISP_TempDispMode = ucDes;
	ucDISP_TempPage = 0;
	DISP_SetBlink();
}

void DISP_ClearTempDisplayMode(void)
{
	usDISP_TempDispMode_Timer50msec = 0;
	ucDISP_TempDispMode = DISP_NONE;
//	DISP_IconSetStatusFlag(ICON_MASK_SCH,0);
}

#ifdef CD
void DISP_SetCDPlayIcon(void)
{
	ucDISP_CD_ICON_Step	= ICON_CDDET_START;
	ucDISP_CD_ICON_Timer5msec = 200/5;
}
#endif

unsigned char ucDISP_ScrollReset;
unsigned short ucDISP_ScrollOffSet;
unsigned char ucDISP_ScrollDisplayedOffSet;
unsigned short ucDISP_Scroll_Timer50msec;

unsigned char DISP_StringLen(unsigned char *ucData, unsigned char ucUni, unsigned short usLimit)
{
	unsigned short usTemp;
	unsigned char i;
	
	if  ((ucUni == 0xF0) || (ucUni == 0xF1) || (ucUni == 0xF2) || (ucUni == 0x00))
	{
		for(i = 0; i < usLimit; ++i)
		{
			usTemp = *ucData;
			if  (usTemp == 0x0000)
			{
				break;
			}
			++ucData;
		}
	}
	else
	{
		for(i = 0; i < usLimit; i = i + 2)
		{
			usTemp = *ucData;
			usTemp = ((usTemp << 8) & 0xFF00) | *(ucData + 1);
			if  (usTemp == 0x0000)
			{
				break;
			}
			++ucData;
			++ucData;
		}
	}

	return(i);
}

void DISP_PageScrollReset(void)
{
	ucDISP_ScrollOffSet = 0;
	ucDISP_ScrollDisplayedOffSet = 0;
	ucDISP_ScrollReset = 0;
	ucDISP_Scroll_Timer50msec = 0;
#ifdef  DOT_SCROLL
	usDISP_DotScroll_Timer5msec = 1000/5;
#endif
}

unsigned char DISP_ConvertToLargeChar(unsigned short usData)
{
	unsigned char ucFont;

	ucFont = (unsigned char)usData;
	
	if  ((ucFont > ('a' - 1)) && (ucFont < ('z' + 1)))
	{
		ucFont = ucFont - 'a';
		ucFont = ucFont + 'A';
	}

	return(ucFont);
}

unsigned short DISP_ConvertUnicodeToAscii(unsigned char *ucBuf, unsigned char *ucData, unsigned char ucUni, unsigned char ucSize)
{
	unsigned char i;
	unsigned short usTemp;
	unsigned char ucCnt = 0;

	if  ((ucUni == 0xF0) || (ucUni == 0xF1) || (ucUni == 0xF2))
	{
		for(i = 0; i < ucSize; ++i)
		{
			if  (*ucData == 0x00)
			{
				break;
			}
			if  ((i == 0) && (*ucData == ' '))
			{
			}
			else
			{
				*ucBuf = DISP_ConvertToLargeChar(*ucData);
				++ucBuf;
			}
			++ucData;
			++ucCnt;
		}
	}
	else
	{
		for(i = 0; i < ucSize; ++i)
		{
			if  ((ucUni == 0xF4) || (ucUni == 0xF7) || (ucUni == 0xF9))
			{
				usTemp = *ucData;
				usTemp = (usTemp << 8) & 0xFF00 | *(ucData + 1);
			}
			else
			{
				usTemp = *(ucData + 1);
				usTemp = (usTemp << 8) & 0xFF00 | *ucData;
			}

			if  (usTemp < 0x0100)
			{
			}
			else
			{
				usTemp = '*';
			}
			if  (usTemp == 0x0000)
			{
				break;
			}

			if  ((i == 0) && (usTemp == 0x0020))
			{
			}
			else
			{
				*ucBuf = DISP_ConvertToLargeChar(usTemp);
				++ucBuf;
			}
			++ucData;
			++ucData;
			++ucCnt;
			++ucCnt;
		}
	}
	return(ucCnt);
}

#ifdef  DOT_SCROLL

unsigned char DISP_DotScroll(unsigned char ucOpt, UI_INFO_MODE ucMode, unsigned char *ucData, unsigned char ucSize, unsigned char ucUni)
{
	unsigned short ucRet;
	unsigned short usStartX;
	
	if  (ucMode == INFO_FOLDERNAME)
	{
	#ifdef  ST7565P
		ST7565_UpdateDisplayImage(1, IMAGE_FOLDER);
	#endif
		usStartX = 16;
	}
	else
	{
		usStartX = 0;
	}

	if  (ucDISP_ScrollEnable == 0)
	{
	#ifdef  ST7565P
		ST7565_UpdateDisplayStringUnicode(usStartX, ucData, ucSize, ucUni);
	#endif
		return(0);
	}

	if  (usDISP_DotScroll_Timer5msec == 0)
	{
		if  (ucDISP_ScrollReset == 1)
		{
			DISP_PageScrollReset();
			if  (ucOpt == 1)
			{
				return(1);
			}
			return(0);
		}
		usDISP_DotScroll_Timer5msec = 100/5;//120/5;
		++ucDISP_ScrollOffSet;
	}

	#ifdef  ST7565P
	ucRet = ST7565_UpdateDisplayStringUnicodeScroll(usStartX, ucDISP_ScrollOffSet, ucData, ucSize, ucUni);
	#endif	

	if  (ucRet == 0)
	{
		ucDISP_ScrollReset = 1;
	}

	if  ((ucRet == 0xFFFF) && (ucDISP_ScrollReset == 0))
	{
		ucDISP_ScrollReset = 1;
		usDISP_DotScroll_Timer5msec = 5000/5;//120/5;
	}
	
	return((unsigned char)ucRet);
}
#endif

unsigned char DISP_PageScroll(unsigned char ucOpt, UI_INFO_MODE ucMode, unsigned char *ucData, unsigned char ucSize, unsigned char ucUni)
{
	unsigned char ucLen;
	unsigned char ucStartX;
	unsigned char ucRet = 0;

#ifdef  DOT_SCROLL
	ucRet = DISP_DotScroll(ucOpt, ucMode, ucData, ucSize, ucUni);
#else	// DOT_SCROLL

#ifdef ST7565P
	if  (ucMode == INFO_FOLDERNAME)
	{
		ST7565_UpdateDisplayImage(1, IMAGE_FOLDER);
		ucStartX = 16;
	}
	else
	{
		ucStartX = 0;
	}
#endif
	if  (ucDISP_ScrollEnable == 0)
	{
	#ifdef  ST7565P
		ST7565_UpdateDisplayStringUnicode(ucStartX, ucData, ucSize, ucUni);
	#endif
	#ifdef  PT6524
		DISP_ConvertUnicodeToAscii(&ucDISP_Buf[3], ucData, ucUni, 9);
	#endif
		return(0);
	}
	if  (ucDISP_Scroll_Timer50msec == 0)
	{
		if  (ucDISP_ScrollReset == 1)
		{
			DISP_PageScrollReset();
			if  (ucOpt == 1)
			{
				return(1);
			}
		}
		ucDISP_Scroll_Timer50msec = 3000/50;
		ucDISP_ScrollDisplayedOffSet = ucDISP_ScrollOffSet;
	#ifdef  ST7565P
		ucDISP_ScrollOffSet = ucDISP_ScrollOffSet + ST7565_UpdateDisplayStringUnicode(ucStartX, ucData + ucDISP_ScrollDisplayedOffSet, ucSize, ucUni);
	#endif
	#ifdef  PT6524
		ucDISP_ScrollOffSet = ucDISP_ScrollOffSet + DISP_ConvertUnicodeToAscii(&ucDISP_Buf[3], ucData + ucDISP_ScrollDisplayedOffSet, ucUni, 9);
	#endif
		if  (ucDISP_ScrollOffSet >= DISP_StringLen(ucData, ucUni, ucSize))
		{
			ucDISP_ScrollReset = 1;
		}
	}
	else
	{
	#ifdef  ST7565P
		ST7565_UpdateDisplayStringUnicode(ucStartX, ucData + ucDISP_ScrollDisplayedOffSet, 0, ucUni);
	#endif
	#ifdef  PT6524
		DISP_ConvertUnicodeToAscii(&ucDISP_Buf[3], ucData + ucDISP_ScrollDisplayedOffSet, ucUni, 9);
	#endif
	}
#endif		// DOT_SCROLL
	return(ucRet);
}

/*/////////////////////////////////////////////////////////////////////////////////////////
Title : void DISP_Display_ClockSub(unsigned char ucHour, unsigned char ucMin, unsigned char ucOpt)
ucOpt
	0x00 : Blink ':'
	0x01 : Blink Hour
	0x02 : Blink Min
	0xFF : Blink nothing
/////////////////////////////////////////////////////////////////////////////////////////*/
void DISP_MainText_ClockSub(unsigned char ucHour, unsigned char ucMin, unsigned char ucOpt)
{
	unsigned char ucBuf[6];

	memset(&ucBuf[0], ' ', 6);
	
	if  (ucOpt != 1)
	{
		if  (ucHour > 12)
		{
			ucHour = ucHour - 12;
		}
		else  if  (ucHour == 0)
		{
			ucHour = 12;
		}
		ucBuf[0] = (ucHour / 10) + '0';
		if  (ucBuf[0] == '0')
		{
			ucBuf[0] = ' ';
		}
		ucBuf[1] = (ucHour % 10) + '0';
	}
	
	if  (ucOpt != 0)
	{
		ucBuf[2] = ':';
	}

	if  (ucOpt != 2)
	{
		ucBuf[3] = (ucMin / 10) + '0';
//		if  (ucBuf[3] == '0')
//		{
//			ucBuf[3] = ' ';
//		}
		ucBuf[4] = (ucMin % 10) + '0';
	}

#ifdef  ST7565P
	ST7565_UpdateDisplayData(31, ucBuf[0]);
	ST7565_UpdateDisplayData(36, ucBuf[1]);
	ST7565_UpdateDisplayData(45, ucBuf[2]);
	ST7565_UpdateDisplayData(50, ucBuf[3]);
	ST7565_UpdateDisplayData(57, ucBuf[4]);
#endif
#ifdef  PT6524
	if  (ucOpt != 0)
	{
		DISP_IconSetStatusFlag(1, ICON_MASK_COL);
	}
	ucDISP_Buf[6] = ucBuf[0];
	ucDISP_Buf[7] = ucBuf[1];
	ucDISP_Buf[8] = ucBuf[3];
	ucDISP_Buf[9] = ucBuf[4];	  
#endif
	
}

#ifdef  ZYLE_LOGO

unsigned char ucDISP_LogoActive;
unsigned char ucDISP_LogoActive_Timer100msec;

void DISP_SetLogo(void)
{
	if  (OPT_GetOption(OPT_MASK_LOGO))
	{
		ucDISP_LogoActive_Timer100msec = 3000/100;
		ucDISP_LogoActive = 1;

		if  (OPT_GetOption(OPT_MASK_CLOCK) == 0)
		{
			PWR_DisplayDriverOn();
		}
	}
}

void DISP_ZyleDaewoo(void)
{
	unsigned char ucBuf[15];

	memset(&ucBuf[0], 0x00, 15);
//	memcpy(&ucBuf[0], "DAEWOO BUS", 10);

#ifdef  ST7565P
	#if  1
	
	ST7565_UpdateDisplayImage(0, IMAGE_D);
	ST7565_UpdateDisplayImage(8, IMAGE_A);
	ST7565_UpdateDisplayImage(17, IMAGE_E);
	ST7565_UpdateDisplayImage(24, IMAGE_W);
	ST7565_UpdateDisplayImage(33, IMAGE_O);
	ST7565_UpdateDisplayImage(41, IMAGE_O);
	
	memcpy(&ucBuf[0], "BUS", 3);
	ST7565_UpdateDisplayString(56, &ucBuf[0], 0);
	#else
	ST7565_UpdateDisplayImage(5, IMAGE_Z);
	ST7565_UpdateDisplayImage(12, IMAGE_Y);
	ST7565_UpdateDisplayImage(19, IMAGE_L);
	ST7565_UpdateDisplayImage(26, IMAGE_E);
	ST7565_UpdateDisplayImage(38, IMAGE_D);
	ST7565_UpdateDisplayImage(46, IMAGE_A);
	ST7565_UpdateDisplayImage(55, IMAGE_E);
	ST7565_UpdateDisplayImage(62, IMAGE_W);
	ST7565_UpdateDisplayImage(71, IMAGE_O);
	ST7565_UpdateDisplayImage(79, IMAGE_O);
	#endif
#endif
}
#endif

void DISP_Display_Mute(void)
{
	unsigned char ucBuf[4];

	memcpy(&ucBuf[0], "MUTE", 4);
	
	if  (ucDISP_Blink == 0)
	{
	#ifdef  ST7565P
		ST7565_UpdateDisplayData(28, ucBuf[0]);
		ST7565_UpdateDisplayData(39, ucBuf[1]);
		ST7565_UpdateDisplayData(48, ucBuf[2]);
		ST7565_UpdateDisplayData(57, ucBuf[3]);
	#endif
	#ifdef  PT6524
		memcpy(&ucDISP_Buf[3], "  MUTE   ", 9);
	#endif
	}
}

void DISP_MainText_Clock(void)
{
	if  (ucDISP_Blink == 1)
	{
		DISP_MainText_ClockSub(ucRTC_Hour, ucRTC_Min, 0x00);
	}
	else
	{
		DISP_MainText_ClockSub(ucRTC_Hour, ucRTC_Min, 0xFF);
	}
}

void DISP_MainText_PowerOff(void)
{
#ifdef  OPTIONAL_CLOCK
	if  (OPT_GetOption(OPT_MASK_CLOCK) == 0)
	{
		return;
	}
#endif
	DISP_MainText_Clock();
}

void DISP_TelMute_SubText(void)
{
	unsigned char ucBuf[3];
	memcpy(&ucBuf[0], "TEL", 3);
		
#ifdef  ST7565P
	ST7565_UpdateSubDisplayData(&ucBuf[0]);	
#endif
#ifdef  PT6524
	memcpy(&ucDISP_Buf[0],&ucBuf[0], 3);	
#endif
}

void DISP_SubText_PowerOn(void) 
{
	unsigned char ucFunc = FUNC_GetCurrentFunction();

	//if	((ucDISP_ClockMode == 1) && (ucDISP_CurrentDisplay_Timer50msec == 0))
	//{
	//	DISP_Display_SubText_Clock();
	//	return;
	//}
	if  (ucAUDIO_TelMute == 1)
	{
		DISP_TelMute_SubText();
		return;
	}
	
#ifdef  MIC
	if  ((MIC_GetMicStatus() == MIC_ON) && (MIC_GetMixMode() == MIX_OFF))
	{
		MIC_DISP_SubText();
		return;
	}
#endif
	
#if	0//def  AUTO_GUIDE
	if	(AG_GetAnnounceStatus() == AG_ANNOUNCE_ON)
	{
		AG_DISP_SubText();
		return;
	}
#endif

	switch	(ucFunc)
	{
		case FUNC_TUNER:
			TUNER_DISP_SubText();
			break;
		case FUNC_USB:
			USB_DISP_SubText();
			break;		
	#ifdef  CD
		case FUNC_CD:
			CD_DISP_SubText();		
			break;
	#endif
		case FUNC_AUX:
			AUX_DISP_SubText();
			break;
	#ifdef  BLUETOOTH
		case FUNC_A2DP:
			BTA_DISP_SubText();
			break;
		case FUNC_HF:
			Bluetooth_DISP_Display_SubText();
			break;
		case FUNC_LPB:
			BT_LPB_DISP_SubText();
			break;
	#endif
	#ifdef  AV_CONTROLLER
		case FUNC_AVC_MODE:
			AVC_MODE_DISP_SubText();
			break;
	#endif
	}

}
void DISP_SubText_PowerOff(void)
{	
#ifdef  OPTIONAL_CLOCK
	if  (OPT_GetOption(OPT_MASK_CLOCK) == 0)
	{
		return;
	}
#endif
	if  (ucMenuID == MENU_NONE)
	{
		UI_DMENU_ClockSet_AM_PM(ucRTC_Hour);
	}
}

void DISP_Volume(void)
{
	unsigned char ucBuf[15];

	memset(&ucBuf[0], ' ', 15);

#ifdef  ST7565P
	ucBuf[0] = 'V';
	ucBuf[1] = 'O';
	ucBuf[2] = 'L';
	ucBuf[3] = 0x00;
	
	ucBuf[4] = (ucAUDIO_Volume / 10) | '0';
	ucBuf[5] = (ucAUDIO_Volume % 10) | '0';
	ucBuf[6] = 0x00;

	ST7565_UpdateDisplayString(7, &ucBuf[0], 0);	
	ST7565_UpdateDisplayString(58,&ucBuf[4], 0);	
#endif

#ifdef  PT6524
	ucDISP_Buf[4] = 'V';
	ucDISP_Buf[5] = 'O';
	ucDISP_Buf[6] = 'L';

	ucDISP_Buf[9] = (ucAUDIO_Volume / 10) | '0';
	ucDISP_Buf[10] = (ucAUDIO_Volume % 10) | '0';
#endif

}
void DISP_No_Info(void)
{	
	unsigned char ucBuf[10];

	memset(&ucBuf[0], 0x00, 10);

#ifdef  ST7565P		
	ucBuf[0] = 'N';
	ucBuf[1] = 'O';
	ucBuf[2] = ' ';
	ucBuf[3] = 'I';
	ucBuf[4] = 'N';
	ucBuf[5] = 'F';
	ucBuf[6] = 'O';

	ST7565_UpdateDisplayString(7, &ucBuf[0], 0);	
#endif

#ifdef  PT6524
	ucDISP_Buf[4] = 'N';
	ucDISP_Buf[5] = 'O';
	ucDISP_Buf[6] = ' ';
	ucDISP_Buf[7] = 'I';
	ucDISP_Buf[8] = 'N';
	ucDISP_Buf[9] = 'F';
	ucDISP_Buf[10] = 'O';
#endif
}
#ifdef  ST_EV_ADJ
extern unsigned char ucST7565_EV_Level;
void DISP_ST_EV_Adjust(void)
{
	unsigned char ucBuf[10];

	memset(&ucBuf[0], ' ', 10);

	ucBuf[0] = 'E';
	ucBuf[1] = 'V';
	ucBuf[2] = ' ';
	
	ucBuf[3] = (ucST7565_EV_Level / 10) | '0';
	ucBuf[4] = (ucST7565_EV_Level % 10) | '0';
	ucBuf[5] = 0x00;

	ST7565_UpdateDisplayString(7, &ucBuf[0], 0);	
}

#endif

void DISP_TEMP_CD_Eject(void)
{
	unsigned char ucBuf[5];
	memcpy(&ucBuf[0], "EJECT", 5);
			
	#ifdef  ST7565P
	ST7565_UpdateDisplayData(7, ucBuf[0]);
	ST7565_UpdateDisplayData(16, ucBuf[1]);
	ST7565_UpdateDisplayData(23, ucBuf[2]);
	ST7565_UpdateDisplayData(32, ucBuf[3]);
	ST7565_UpdateDisplayData(41, ucBuf[4]);
	#endif                       
}           

#ifdef MODEL_AGC5030	
char  const *ucDISP_TempDisplayString[] =
{
	"             ",
	"NO MECHA     ",
	"NO CD        ",
	"NO USB       ",
	"NO AUX       ",
	"ASIA         ",
	"North America",
	"South America",
	"Europe       "
};
#endif
#ifdef MODEL_AGC505X	
char  const *ucDISP_TempDisplayString[] =
{
	"             ",
	"NO MECHA     ",
	"NO CD        ",
	"NO USB       ",
	"NO AUX       ",
	"ASIA         ",
	"North America",
	"South America",
	"Europe       "
};
#endif
#ifdef  MODEL_ARA5040
char  const *ucDISP_TempDisplayString[] =
{
    "         ",
	"NO MECHA ",
	" NO CD   ",
	" NO USB  ",
	" NO AUX  ",
	"  ASIA   ",
	"N AMERICA",
	"S AMERICA",
	"  EUROPE "
};
#endif
#ifdef  BLUETOOTH
extern unsigned char ucMV_FirmwareVersion[4];
#endif

void DISP_Temp_FirmwareUpdate(unsigned char ucMode)
{
	unsigned char ucBuf[14];
	unsigned char ucBufSize;
	unsigned char i;
	unsigned char j;
	
	memset(&ucBuf[0], 0x00, 14);
	
	switch  (ucMode)
	{
		case DISP_FIRMWARE_HOST:
		#ifdef  ST7565P
			memcpy(&ucBuf[0],"5050",4);
			if  (OPT_GetOption(OPT_MASK_AVC))
			{
				ucBuf[3] = '1';
			}
			if  (OPT_GetOption(OPT_MASK_CD))
			{
				ucBuf[2] = '5';
			}
			else
			{
				ucBuf[2] = '6';
			}
			memcpy(&ucBuf[4], FIRMWARE_VERSION, 5);
			ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
		#endif
			break;
	#ifdef  BLUETOOTH
		case DISP_FIRMWARE_BLUETOOTH:
		#ifdef  ST7565P
			memcpy(&ucBuf[0],"BT ",3);
			ucBuf[3] = ((ucMV_FirmwareVersion[0] >> 4) & 0x0F) + '0';
			ucBuf[4] = (ucMV_FirmwareVersion[0] & 0x0F) + '0';
			
			ucBuf[5] = ((ucMV_FirmwareVersion[1] >> 4) & 0x0F) + '0';
			ucBuf[6] = (ucMV_FirmwareVersion[1] & 0x0F) + '0';
			
			ucBuf[7] = ((ucMV_FirmwareVersion[2] >> 4) & 0x0F) + '0';
			ucBuf[8] = (ucMV_FirmwareVersion[2] & 0x0F) + '0';
			
			ucBuf[9] = ((ucMV_FirmwareVersion[3] >> 4) & 0x0F) + '0';
			ucBuf[10] = (ucMV_FirmwareVersion[3] & 0x0F) + '0';
			ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
		#else
		#endif
			break;

	#endif
		case DISP_FIRMWARE_USB:
		#ifdef  ST7565P
			ucBuf[0] = 'D';
			ucBuf[1] = 'E';
			ucBuf[2] = 'C';
			ucBuf[3] = 'K';
			ucBuf[4] = ' ';
			ucBuf[5] = 'V';
			ucBuf[6] = ucLC786XXX_SequencerVersion[0];
			ucBuf[7] = ucLC786XXX_SequencerVersion[1];
			ucBuf[8] = ucLC786XXX_SequencerVersion[2];
			ucBuf[9] = ucLC786XXX_SequencerVersion[3];
			
			ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
		#else
			memcpy(&ucDISP_Buf[3],"USB ",4);
			ucDISP_Buf[7] = 'V';
			j = 0;
			for ( i=0; i<4; ++i )
			{
				if  ( ucLC786XXX_SequencerVersion[i] != '.' )
				{
					ucDISP_Buf[8 + j] = ucLC786XXX_SequencerVersion[i];
					++j;
				}
			}
		#endif
			break;
	}
}

void DISP_Temp_EQFlat(unsigned char ucMode)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);

	#ifdef  ST7565P
	memcpy(&ucBuf[0],"EQ Flat",7);
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
	#endif

	#ifdef  PT6524
	memcpy(&ucDISP_Buf[3],"EQ FLAT",7);
	#endif
}


void DISP_Temp_NoUSB(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);

	
	#ifdef  ST7565P
			memcpy(&ucBuf[0],"No USB",6);
			ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
	#endif

	#ifdef  PT6524
			memcpy(&ucDISP_Buf[3],"NO USB",6);
	#endif

}

void DISP_Temp_USBCheck(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);

	#ifdef  ST7565P
			memcpy(&ucBuf[0],"Check USB",9);
			ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
	#endif

	#ifdef  PT6524
			memcpy(&ucDISP_Buf[3],"CHECK USB",9);
	#endif		
}
#ifdef  FILE_SEARCH
void DISP_Temp_FileSearch(void)
{
	if  (FUNC_GetCurrentFunction()== FUNC_USB)
	{
		USB_DISP_FileSearch();
	}
#ifdef  CD
	if  (FUNC_GetCurrentFunction()== FUNC_CD)
	{
		CD_DISP_FileSearch();
	}
#endif
}
#endif

void DISP_LC786X_FirmwereUpdatePercent(unsigned char ucData)
{
	unsigned char ucBuf[15];
	
	memset(&ucBuf[0], 0x00, 15);

	
#ifdef  ST7565P
		ucBuf[0] = 'U';
		ucBuf[1] = 'p';
		ucBuf[2] = 'd';
		ucBuf[3] = 'a';
		ucBuf[4] = 't';
		ucBuf[5] = 'e';
		ucBuf[6] = ' ';
		ucBuf[7] = (ucData / 10) + '0';
		ucData = ucData % 10;
		ucBuf[8] = ucData + '0';
		ucBuf[9] = '%';
		ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif	
	
#ifdef  PT6524	
		ucDISP_Buf[3] = 'U';
		ucDISP_Buf[4] = 'P';
		ucDISP_Buf[5] = 'D';
		ucDISP_Buf[6] = 'A';
		ucDISP_Buf[7] = 'T';
		ucDISP_Buf[8] = 'E';
		ucDISP_Buf[9] = ' ';
		ucDISP_Buf[10] = (ucData / 10) + '0';
		ucData = ucData % 10;
		ucDISP_Buf[11] = ucData + '0';
#endif

}

void DISP_Temp_NoFile(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);
	#ifdef  ST7565P
			memcpy(&ucBuf[0],"No File",7);
			ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
	#endif	
	
	#ifdef  PT6524	
			memcpy(&ucDISP_Buf[3],"NO FILE",7);
	#endif

		
}
void DISP_Temp_FirmwereUpdateStart(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);
#ifdef  ST7565P
	memcpy(&ucBuf[0],"Start",5);
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif	
	
#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3],"START",5);
#endif
}
void DISP_Temp_FirmwereUpdateComplete(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);

#ifdef  ST7565P
	memcpy(&ucBuf[0],"Complete",8);
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif	
	
#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3],"COMPLETE",8);
#endif

}
void DISP_Temp_FirmwereUpdateError(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);
#ifdef  ST7565P
	memcpy(&ucBuf[0],"File Error",10);
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif	

#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3],"FILE ERR",8);
#endif
}
void DISP_Temp_FirmwereUpdateFail(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);
#ifdef  ST7565P
	memcpy(&ucBuf[0],"Update Fail",11);
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif	
	
#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3],"FAIL",4);
#endif
}

#ifdef	AV_CONTROLLER

void DISP_Temp_AVC_DrvOn(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);
	memcpy(&ucBuf[0],"DRV-ON",6);
#ifdef  ST7565P
	ST7565_UpdateDisplayString(20, &ucBuf[0], 0);
#endif
}

void DISP_Temp_AVC_DrvOff(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);
	memcpy(&ucBuf[0],"DRV-OFF",7);
#ifdef  ST7565P
	ST7565_UpdateDisplayString(20, &ucBuf[0], 0);
#endif
}

void DISP_Temp_SP_On(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);
	memcpy(&ucBuf[0],"SEL-ON",6);
#ifdef  ST7565P
	ST7565_UpdateDisplayString(20, &ucBuf[0], 0);
#endif
}

void DISP_Temp_SP_Off(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);
	memcpy(&ucBuf[0],"SEL-OFF",7);
#ifdef  ST7565P
	ST7565_UpdateDisplayString(20, &ucBuf[0], 0);
#endif
}

void DISP_Temp_MIC_Off(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);
	memcpy(&ucBuf[0],"MIC OFF",7);
#ifdef  ST7565P
	ST7565_UpdateDisplayString(20, &ucBuf[0], 0);
#endif
}

void DISP_Temp_MIC_On(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);
	memcpy(&ucBuf[0],"MIC ON",6);
#ifdef  ST7565P
	ST7565_UpdateDisplayString(20, &ucBuf[0], 0);
#endif
}

void DISP_Temp_MIX_On(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);
	memcpy(&ucBuf[0],"MIX ON",6);
#ifdef  ST7565P
	ST7565_UpdateDisplayString(20, &ucBuf[0], 0);
#endif
}

void DISP_Temp_MIX_Off(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);
	memcpy(&ucBuf[0],"MIX OFF",7);
#ifdef  ST7565P
	ST7565_UpdateDisplayString(20, &ucBuf[0], 0);
#endif
}

#endif

#ifdef	DRV_SPK
void DISP_Temp_DriverSpeaker(void)
{
	unsigned char ucBuf[14];
	
	memset(&ucBuf[0], 0x00, 14);
	
	switch  (AUDIO_GetSpeakerMode())
	{
		case DSPK_ALL:
		#ifdef  ST7565P
			memcpy(&ucBuf[0],"SP-ALL",6);
			ST7565_UpdateDisplayString(15, &ucBuf[0], 0);
		#endif
			break;
		case DSPK_DRIVER:
		#ifdef  ST7565P
			memcpy(&ucBuf[0],"SP-DRV",6);
			ST7565_UpdateDisplayString(15, &ucBuf[0], 0);
		#endif
			break;
		case DSPK_PSG:
		#ifdef  ST7565P
			memcpy(&ucBuf[0],"SP-PSG",6);
			ST7565_UpdateDisplayString(15, &ucBuf[0], 0);
		#endif
			break;
	}
}
#endif


void DISP_Temp_TunerPresetClear(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);
#ifdef  ST7565P
	memcpy(&ucBuf[0],"P CLEAR",7);
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif	
	
#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3],"P CLEAR",7);
#endif
}

void DISP_Temp_Local_NorthAmerica(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);
#ifdef  ST7565P
	memcpy(&ucBuf[0],"N America",9);
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif	
	
#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3],"N AMERICA",9);
#endif
}
void DISP_Temp_Local_SouthAmerica(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);
#ifdef  ST7565P
	memcpy(&ucBuf[0],"S America",9);
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif	
	
#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3],"S AMERICA",9);
#endif
}
void DISP_Temp_Local_Asia(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);
#ifdef  ST7565P
	memcpy(&ucBuf[0],"Asia",4);
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif	
	
#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3],"ASIA",4);
#endif
}
void DISP_Temp_Local_Europe(void)
{
	unsigned char ucBuf[14];

	memset(&ucBuf[0], 0x00, 14);
#ifdef  ST7565P
	memcpy(&ucBuf[0],"Europe",6);
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif	
	
#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3],"EUROPE",6);
#endif
}

void DISP_Temp_TunerInfo(void)
{
	unsigned char ucLevel;
	unsigned char ucMulti;
	unsigned char ucUltra;
	unsigned char ucBlend;
	unsigned char ucBuf[14];
	unsigned short usNumber;	

	memset(&ucBuf[0], 0x00, 14);

#ifdef  ATOMIC
	ucLevel = ATOMIC_GetSignalLevel();
	ucMulti = ATOMIC_GetMultiPath();
	ucUltra = ATOMIC_GetUltraSonicNoise();
	ucBlend = ATOMIC_GetStereoBlend();
#endif
#ifdef  HERO
	ucLevel = HERO_GetSignalLevel();
	ucMulti = HERO_GetMultiPath();
	ucUltra = HERO_GetUltraSonicNoise();
	ucBlend = HERO_GetStereoBlend();
#endif
#ifdef  ST7565P
	if  (ucDISP_RadioInfo_Active == 0x01)
	{
		ucBuf[0] = 'L';
		ucBuf[1] = ucLevel / 10 + '0';
		ucBuf[2] = ucLevel % 10 + '0';

		ucBuf[3] = ' ';
		
		ucBuf[4] = 'M';
		ucBuf[5] = ucMulti / 100 + '0';
		usNumber = (ucMulti % 100);
		ucBuf[6] = (usNumber / 10) + '0';
		usNumber = (usNumber % 10);
		ucBuf[7] = usNumber + '0';
	}
	else
	{
		ucBuf[0] = 'U';
		ucBuf[1] = ucUltra / 100 + '0';
		usNumber = (ucUltra % 100);
		ucBuf[2] = (usNumber / 10) + '0';
		usNumber = (usNumber % 10);
		ucBuf[3] = usNumber + '0';

		ucBuf[4] = ' ';
		
		ucBuf[5] = 'B';
		ucBuf[6] = ucBlend / 100 + '0';
		usNumber = (ucBlend % 100);
		ucBuf[7] = (usNumber / 10) + '0';
		usNumber = (usNumber % 10);
		ucBuf[8] = usNumber + '0';
	}
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif	
	
#ifdef  PT6524	
	if  (ucDISP_RadioInfo_Active == 0x01)
	{
		ucDISP_Buf[3] = 'L';
		ucDISP_Buf[4] = ucLevel / 10 + '0';
		ucDISP_Buf[5] = ucLevel % 10 + '0';

		ucDISP_Buf[6] = ' ';
		
		ucDISP_Buf[7] = 'M';
		ucDISP_Buf[8] = ucMulti / 10 + '0';
		ucDISP_Buf[9] = ucMulti % 10 + '0';
	}
	else
	{
		ucDISP_Buf[3] = 'U';
		ucDISP_Buf[4] = ucUltra / 10 + '0';
		ucDISP_Buf[5] = ucUltra % 10 + '0';

		ucDISP_Buf[6] = ' ';
		
		ucDISP_Buf[7] = 'B';
		ucDISP_Buf[8] =  ucBlend / 100 + '0';
		usNumber = (ucBlend % 100);
		ucDISP_Buf[9] = (usNumber / 10) + '0';
		usNumber = (usNumber % 10);
		ucDISP_Buf[10] = usNumber + '0';
	}
#endif
}

void DISP_ErrorCode_NoFile(void)
{
	unsigned char ucBuf[14];
	
	memset(&ucBuf[0], 0x00, 14);
	memcpy(&ucBuf[0], "NO FILE", 7);
#ifdef  ST7565P	
	ST7565_UpdateDisplayString(4,&ucBuf[0], 0);
#endif	
	
#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3], "NO FILE", 7);
#endif
}           

void DISP_ErrorCode_ErrXX(void)
{	
	unsigned char ucBuf[14];
	unsigned char ucErrorCode;
	
	memset(&ucBuf[0], 0x00, 14);	
	memcpy(&ucBuf[0], "ERR", 3);

	ucErrorCode = DRV_LC786XXX_BCDToHex(LC786XXX_GetErrorCode(ucLC786XXX_CurrentMediaID));	
	ucBuf[4] = (ucErrorCode / 10) + '0';
	ucBuf[5] = (ucErrorCode % 10) + '0';
	ucBuf[6] = 0x00;	
					
#ifdef  ST7565P
	ST7565_UpdateDisplayString(4,&ucBuf[0], 0);
	ST7565_UpdateDisplayString(40,&ucBuf[4], 0);
#endif	
	
#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3], "ERR", 3);
	ucDISP_Buf[7] = (ucErrorCode / 10) + '0';
	ucDISP_Buf[8] = (ucErrorCode % 10) + '0';
#endif	
}
#ifdef  CD
void DISP_CD_ErrorCode_Err00(void)
{	
	unsigned char ucBuf[14];
	unsigned char ucErrorCode;
	
	memset(&ucBuf[0], 0x00, 14);	
	memcpy(&ucBuf[0], "ERR", 3);

	ucErrorCode = DRV_LC786XXX_BCDToHex(ucCD_ErrorCode);	
	ucBuf[4] = (ucErrorCode / 10) + '0';
	ucBuf[5] = (ucErrorCode % 10) + '0';
	ucBuf[6] = 0x00;	
					
#ifdef  ST7565P
	ST7565_UpdateDisplayString(4,&ucBuf[0], 0);
	ST7565_UpdateDisplayString(40,&ucBuf[4], 0);
#endif
}
#endif
void DISP_USB_ErrorCode_Err00(void)
{	
	unsigned char ucBuf[14];
	unsigned char ucErrorCode;
	
	memset(&ucBuf[0], 0x00, 14);	
	memcpy(&ucBuf[0], "ERR", 3);

	ucErrorCode = DRV_LC786XXX_BCDToHex(ucUSB_ErrorCode);	
	ucBuf[4] = (ucErrorCode / 10) + '0';
	ucBuf[5] = (ucErrorCode % 10) + '0';
	ucBuf[6] = 0x00;	
					
#ifdef  ST7565P
	ST7565_UpdateDisplayString(4,&ucBuf[0], 0);
	ST7565_UpdateDisplayString(40,&ucBuf[4], 0);
#endif	
	
#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3], "ERR", 3);
	ucDISP_Buf[7] = (ucErrorCode / 10) + '0';
	ucDISP_Buf[8] = (ucErrorCode % 10) + '0';
#endif	
}

void DISP_ErrorCode_DrmError(void)
{	
	unsigned char ucBuf[14];
	
	memset(&ucBuf[0], 0x00, 14);	
	memcpy(&ucBuf[0], "DRM ERR", 7);
#ifdef  ST7565P
	ST7565_UpdateDisplayString(4,&ucBuf[0], 0);
#endif	
	
#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3], "DRM ERR", 7);
#endif
}

void DISP_ErrorCode_UsbError(void)
{	
	unsigned char ucBuf[14];
	
	memset(&ucBuf[0], 0x00, 14);
	memcpy(&ucBuf[0], "USB ERR", 7);
#ifdef  ST7565P
	ST7565_UpdateDisplayString(4,&ucBuf[0], 0);
#endif
	
#ifdef  PT6524
	memcpy(&ucDISP_Buf[3], "USB ERR", 7);
#endif
}

void DISP_ErrorCode_DecError(void)
{	
	unsigned char ucBuf[14];
	
	memset(&ucBuf[0], 0x00, 14);
	memcpy(&ucBuf[0], "DEC ERR", 7);
#ifdef  ST7565P
	ST7565_UpdateDisplayString(4,&ucBuf[0], 0);
#endif	
	
#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3], "DEC ERR", 7);
#endif
}

void DISP_ErrorCode_FrameError(void)
{	
	unsigned char ucBuf[14];
	
	memset(&ucBuf[0], 0x00, 14);
	memcpy(&ucBuf[0], "FRAME ERR", 9);
#ifdef  ST7565P
	ST7565_UpdateDisplayString(4,&ucBuf[0], 0);
#endif	
	
#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3], "FRAME ERR", 9);
#endif
}

void DISP_ErrorCode_SizeError(void)
{	
	unsigned char ucBuf[14];
	
	memset(&ucBuf[0], 0x00, 14);
	memcpy(&ucBuf[0], "SIZE ERR", 8);
#ifdef  ST7565P
	ST7565_UpdateDisplayString(4,&ucBuf[0], 0);
#endif	
	
#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3], "SIZE ERR", 8);
#endif
}

void DISP_EC_OpenError(void)
{	
	unsigned char ucBuf[14];
	
	memset(&ucBuf[0], 0x00, 14);
	memcpy(&ucBuf[0], "OPEN ERR", 8);
#ifdef  ST7565P
	ST7565_UpdateDisplayString(4,&ucBuf[0], 0);
#endif	
	
#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3], "OPEN ERR", 8);
#endif
}

void DISP_Temp_TunerSeekTest(void)
{
	unsigned char ucBuf[14];
	unsigned char ucSeekStopLevel;

	memset(&ucBuf[0], 0x00, 14);

#ifdef  ATOMIC
	if  (TUNER_CurrentBandType() == FM)
	{
		ucSeekStopLevel = ATOMIC_FM_GetSeekStopLevel();
	}
	else
	{
		ucSeekStopLevel = ATOMIC_AM_GetSeekStopLevel();
	}
#endif
	
#ifdef  HERO
		if	(TUNER_CurrentBandType() == FM)
		{
			ucSeekStopLevel = HERO_FM_GetSeekStopLevel();
		}
		else
		{
			ucSeekStopLevel = HERO_AM_GetSeekStopLevel();
		}
#endif

	#ifdef  ST7565P
	memcpy(&ucBuf[0],"SEEK",4);

	ucBuf[4] = ' ';
	ucBuf[5] = ucSeekStopLevel / 100 + '0';
	ucSeekStopLevel = ucSeekStopLevel % 100;
	ucBuf[6] = ucSeekStopLevel / 10 + '0';
	ucBuf[7] = ucSeekStopLevel % 10+ '0';
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
	#endif	
	
	#ifdef  PT6524	
	memcpy(&ucDISP_Buf[3],"SEEK",4);

	ucDISP_Buf[7] = ' ';
	ucDISP_Buf[8] = ucSeekStopLevel / 100 + '0';
	ucSeekStopLevel = ucSeekStopLevel % 100;
	ucDISP_Buf[9] = ucSeekStopLevel / 10 + '0';
	ucDISP_Buf[10] = ucSeekStopLevel % 10+ '0';
	#endif
}

void DISP_TempString(unsigned char ucMode)
{
	unsigned char ucBuf[14];
	unsigned char ucBufSize;
	
	memset(&ucBuf[0], ' ', 14);
	
#ifdef ST7565P
	ucBufSize = 13;
#endif
#ifdef  PT6524
	ucBufSize = 9;
#endif

	switch  (ucDISP_TempDispMode)
	{
		case DISP_NO_MECH:
		#ifdef ST7565P
			memcpy(&ucBuf[0],ucDISP_TempDisplayString[ucMode],ucBufSize);
			ST7565_UpdateDisplayData(7, ucBuf[0]);		
			ST7565_UpdateDisplayData(16, ucBuf[1]);		
			ST7565_UpdateDisplayData(31, ucBuf[3]);		
			ST7565_UpdateDisplayData(42, ucBuf[4]);		
			ST7565_UpdateDisplayData(51, ucBuf[5]);	
			ST7565_UpdateDisplayData(60, ucBuf[6]);	
			//ST7565_UpdateDisplayData(69, ucBuf[7]);	
		#endif
		#ifdef  PT6524
			memcpy(&ucDISP_Buf[3],ucDISP_TempDisplayString[ucMode],9);
		#endif
			break;
		case DISP_NO_CD:
		#ifdef ST7565P
			memcpy(&ucBuf[0],ucDISP_TempDisplayString[ucMode],ucBufSize);
			ucBuf[5] = 0x00;
			ST7565_UpdateDisplayData(14, ucBuf[0]);		
			ST7565_UpdateDisplayData(23, ucBuf[1]);		
			ST7565_UpdateDisplayString(38, &ucBuf[3], 0);		
		#endif
		#ifdef  PT6524
			memcpy(&ucDISP_Buf[3],ucDISP_TempDisplayString[ucMode],9);
		#endif
			break;
		case DISP_NO_USB:
		#ifdef ST7565P
			memcpy(&ucBuf[0],ucDISP_TempDisplayString[ucMode],ucBufSize);
			ucBuf[6] = 0x00;
			ST7565_UpdateDisplayData(14, ucBuf[0]);		
			ST7565_UpdateDisplayData(23, ucBuf[1]);		
			ST7565_UpdateDisplayString(38, &ucBuf[3],0);
		#endif
		#ifdef  PT6524
			memcpy(&ucDISP_Buf[3],ucDISP_TempDisplayString[ucMode],9);
		#endif
			break;
		case DISP_NO_AUX:		
		#ifdef ST7565P
			memcpy(&ucBuf[0],ucDISP_TempDisplayString[ucMode],ucBufSize);
			ucBuf[6] = 0x00;
			ST7565_UpdateDisplayData(14, ucBuf[0]);		
			ST7565_UpdateDisplayData(23, ucBuf[1]);		
			ST7565_UpdateDisplayString(38, &ucBuf[3],0);		
		#endif
		#ifdef  PT6524
			memcpy(&ucDISP_Buf[3],ucDISP_TempDisplayString[ucMode],9);
		#endif
			break;
		case DISP_VOLUME:
			DISP_Volume();
			break;	
	}
}
#ifdef BLUETOOTH

void DISP_BT_Temp_BluetoothTest(void)
{
	unsigned char ucBuf[15];
	
	memset(&ucBuf[0], 0x00, 15);	
	memcpy(&ucBuf[0], "BT TEST", 7);
	
#ifdef ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif
}

void DISP_BT_Temp_BluetoothADD1(void)
{
	unsigned char ucBuf[15];
	
	memset(&ucBuf[0], 0x00, 15);	
	memcpy(&ucBuf[0], "BT ADD1", 7);
	
#ifdef ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif
}

void DISP_BT_Temp_BluetoothADD2(void)
{
	unsigned char ucBuf[15];
	
	memset(&ucBuf[0], 0x00, 15);	
	memcpy(&ucBuf[0], "BT ADD2", 7);
	
#ifdef ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif
}

void DISP_BT_Temp_BluetoothMIC(void)
{
	unsigned char ucBuf[15];
	
	memset(&ucBuf[0], 0x00, 15);	
	memcpy(&ucBuf[0], "BT MIC", 6);
	
#ifdef ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif
}

void DISP_BT_Temp_BluetoothDUT(void)
{
	unsigned char ucBuf[15];
	
	memset(&ucBuf[0], 0x00, 15);	
	memcpy(&ucBuf[0], "BT DUT", 6);
	
#ifdef ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif
}

void DISP_BT_Temp_Volume(void)
{
	unsigned char ucBuf[10];
		
	memset(&ucBuf[0], ' ', 10);
				
	ucBuf[0] = 'B';
	ucBuf[1] = 'T';
	ucBuf[2] = ' ';
	ucBuf[3] = 'V';
	ucBuf[4] = 'O';
	ucBuf[5] = 'L';
	
	ucBuf[6] = (ucBT_Volume / 10) | '0';
	ucBuf[7] = (ucBT_Volume % 10) | '0';
	ucBuf[8] = 0x00;
			
#ifdef  ST7565P
	ST7565_UpdateDisplayData(7, ucBuf[0]);
	ST7565_UpdateDisplayData(16, ucBuf[1]);
		
	ST7565_UpdateDisplayData(30, ucBuf[3]);
	ST7565_UpdateDisplayData(39, ucBuf[4]);
	ST7565_UpdateDisplayData(49, ucBuf[5]);
		
	ST7565_UpdateDisplayString(62, &ucBuf[6], 0);
#endif

}

void DISP_BT_Temp_ConncetDeviceName(void)
{	
#ifdef ST7565P
	ST7565_UpdateDisplayStringUnicode(0, BT_GetConnectedDeviceName(),0, 0xF3);
#endif
}

void DISP_BT_Temp_Connect(void)
{
	unsigned char ucBuf[15];

	if  (ucDISP_TempPage > 5)
	{
		DISP_BT_Temp_ConncetDeviceName();
		return;
	}
	memset(&ucBuf[0], 0x00, 15);	
	memcpy(&ucBuf[0], "BT CONNECT", 10);
	//ucBuf[10] = 0;
	
#ifdef ST7565P
#if  1
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#else
	ST7565_UpdateDisplayData(7, ucBuf[0]);
	ST7565_UpdateDisplayData(16, ucBuf[1]);
	ST7565_UpdateDisplayData(30, ucBuf[3]);
	ST7565_UpdateDisplayData(39, ucBuf[4]);
	ST7565_UpdateDisplayData(46, ucBuf[5]);
	ST7565_UpdateDisplayData(53, ucBuf[6]);
	ST7565_UpdateDisplayData(60, ucBuf[7]);
	ST7565_UpdateDisplayData(67, ucBuf[8]);
	ST7565_UpdateDisplayData(74, ucBuf[9]);
#endif
#endif

}

void DISP_BT_Temp_Noconncet(void)
{
	unsigned char ucBuf[15];

	memset(&ucBuf[0], 0x00, 15);			
	memcpy(&ucBuf[0], "NO Connect", 10);
	
#ifdef ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif
}

void DISP_TEMP_BT_Icon_DeviceName(void)
{
	unsigned char ucBuf[40];

	memset(&ucBuf[0], 0x00, 40);
	ST7565_UpdateDisplayImage(0, IMAGE_BT);
	memcpy(&ucBuf[0], &ucDISP_BluetoothName[0], BT_DEVICE_NAME_LENGTH);
#ifdef  ST7565P		
	ST7565_UpdateDisplayStringUnicode(12,&ucBuf[0],0,0xF3);
#endif
}

void DISP_BT_Temp_PairNoDevice(void)
{
	unsigned char ucBuf[15];
	
	memset(&ucBuf[0], 0x00, 15);	

	if  (ucDISP_TempPage < 5)
	{
		memcpy(&ucBuf[0], "NO DEVICE ", 9);	
	}
	else
	{
		memcpy(&ucBuf[0], "PAIRED ", 6);
	}
	
#ifdef ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif	

}

void DISP_BT_Temp_PairCancel(void)
{
	unsigned char ucBuf[15];
	
	memset(&ucBuf[0], 0x00, 15);
	memcpy(&ucBuf[0], "Pair Cancel", 11);
	
#ifdef ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif	

}

void DISP_BT_Temp_NoList(void)
{
	unsigned char ucBuf[15];
	
	memset(&ucBuf[0], 0x00, 15);			
	memcpy(&ucBuf[0], "NO LIST", 7);
	
#ifdef ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif	

}

void DISP_BT_Temp_ListFull(void)
{
	unsigned char ucBuf[15];
	
	memset(&ucBuf[0], 0x00, 15);
	
	memcpy(&ucBuf[0], "DEVICE FULL", 11);
#ifdef ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif	
}

void DISP_BT_Temp_ModeSet(void)
{
	unsigned char ucBuf[15];
	
	memset(&ucBuf[0], 0x00, 15);

	if  (ucBT_Function_Active == 1)
	{
		memcpy(&ucBuf[0], "BT ON", 5);	
	}
	else
	{
		memcpy(&ucBuf[0], "BT OFF", 6);
	}
		
	#ifdef ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
	#endif
}

void DISP_BT_Temp_CallIn(void)
{
	unsigned char ucBuf[15];

	memset(&ucBuf[0], 0x00, 15);
	memcpy(&ucBuf[0], "Call In", 7);
	
#ifdef  ST7565P
	if  (ucMV_CallStatus == MV_CALL_INCOMING)
	{
		if  (ucDISP_Blink == 1)
		{
			return;
		}
	}

	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif
	
}	

void DISP_BT_Temp_AcceptCall(void)
{
	unsigned char ucBuf[15];

	memset(&ucBuf[0], 0x00, 15);	
	memcpy(&ucBuf[0], "Accept Call", 11);
	
#ifdef  ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif

}

void DISP_BT_Temp_CallMiss(void)
{
	unsigned char ucBuf[15];	
	
	switch (ucDISP_TempPage)
	{
		case 0:
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:			
			memset(&ucBuf[0], 0x00, 15);
			memcpy(&ucBuf[0], "Call Miss", 9);	
		#ifdef  ST7565P
				ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
		#endif
			break;
		default:
		#ifdef  ST7565P
			if  (ucDISP_PBAPSearchResult == 1)
			{
				if  (sPBAP_List.ucCharSet == PBAP_CHAR_UTF8)
				{
					ST7565_UpdateDisplayStringUnicode(0, &sPBAP_List.ucName[0], 1, 0xF3);
				}
				else
				{
					ST7565_UpdateDisplayString(0, &sPBAP_List.ucName[0], 1);
				}
			}
			else
			{
				ST7565_UpdateDisplayString(0, &ucDISP_BT_CallerID[0], 1); 
			}
		#endif		
	}
}

void DISP_BT_Temp_CallReject(void)
{
	unsigned char ucBuf[15];

	memset(&ucBuf[0], 0x00, 15);
	memcpy(&ucBuf[0], "Call Reject", 11);	
	
#ifdef  ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif

}

void DISP_BT_Temp_CallEnd(void)
{
	unsigned char ucBuf[15];
	
	memset(&ucBuf[0], 0x00, 15);
	memcpy(&ucBuf[0], "Call End", 8);	
	
#ifdef  ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif

}

void DISP_BT_Temp_RecentCall(void)
{
	unsigned char ucBuf[15];
	 
	memset(&ucBuf[0], 0x00, 15);
	memcpy(&ucBuf[0], "Recent calls", 12);	
	
#ifdef  ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif

}

void DISP_BT_Temp_Redial(void)
{				
	unsigned char ucBuf[15];

	memset(&ucBuf[0], 0x00, 15);
	memcpy(&ucBuf[0], "REDIAL", 6);
	
#ifdef  ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif

}

void DISP_BT_Temp_Forward(void)
{
	unsigned char ucBuf[15];

	memset(&ucBuf[0], 0x00, 15);
	memcpy(&ucBuf[0], "BT FWD", 6);
	
#ifdef  ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif

}

void DISP_BT_Temp_Rewind(void)
{
	unsigned char ucBuf[15];

	memset(&ucBuf[0], 0x00, 15);
	memcpy(&ucBuf[0], "BT RWD", 6);
	
#ifdef  ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif

}

extern unsigned char ucBT_MIC_Volume;
void DISP_BT_Temp_MIC_Volume(void)
{
	unsigned char ucBuf[15];

	memset(&ucBuf[0], 0x00, 15);
	memcpy(&ucBuf[0], "MIC VOL ", 8);

	ucBuf[8] = (ucBT_MIC_Volume / 10) + '0';
	ucBuf[9] = (ucBT_MIC_Volume % 10) + '0';
#ifdef  ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 0);
#endif

}


void DISP_BT_PhonebookDownloadStart(void)
{
	unsigned char ucBuf[15];

	memset(&ucBuf[0], 0x00, 15);

	switch  (ucDISP_TempPage)
	{
		default:
			ucDISP_TempPage = 0;
		case 0:
		case 1:
		case 2:
			memcpy(&ucBuf[0], "Phone Book", 10);
			break;
		case 3:
		case 4:
		case 5:
			memcpy(&ucBuf[0], "Downloading", 11);
			break;
	}
#ifdef  ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif
}

void DISP_BT_PhonebookDownloadEnd(void)
{
	unsigned char ucBuf[15];

	memset(&ucBuf[0], 0x00, 15);
	if  (ucDISP_TempPage < 5)
	{
		memcpy(&ucBuf[0], "Download", 8);
	}
	else
	{
		memcpy(&ucBuf[0], "Complete", 8);
	}
	
#ifdef  ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif
}


void DISP_BT_PhonebookDelete(void)
{
	unsigned char ucBuf[15];

	memset(&ucBuf[0], 0x00, 15);
	memcpy(&ucBuf[0], "PB Deleted", 10);
	
#ifdef  ST7565P
	ST7565_UpdateDisplayString(0, &ucBuf[0], 1);
#endif
}

#endif


void DISP_ErrorCode(void)
{	
	switch	(LC786XXX_GetErrorCode(ucLC786XXX_CurrentMediaID))
	{
		case LC786X_EC_NoFile: 
			DISP_ErrorCode_NoFile();
			break;		
		case LC786X_EC_FlashError: 					//0Fh    
		case LC786X_EC_MirrorDetect: 				//11h
		case LC786X_EC_FocusError: 					//12h
		case LC786X_EC_FileAnalyzeError: 			//13h
		case LC786X_EC_PVD_SVD_ReadError: 			//15h
		case LC786X_EC_No_PVD_SVD: 					//16h
		case LC786X_EC_TrackingError: 				//19h
		case LC786X_EC_AutoAdjustError: 			//20h
		case LC786X_EC_SearchError: 				//21h
		case LC786X_EC_TOC_ReadError: 				//22h
		case LC786X_EC_SubCodeReadError: 			//24h
		case LC786X_EC_PUIN_SW_ON_Error: 			//31h
		case LC786X_EC_DSP_CommunicationError: 		//32h
		case LC786X_EC_PUIN_SW_OFF_Error: 			//33h
		case LC786X_EC_AudioDecoderInitializeError: //34h  
		case LC786X_EC_SDRAM_Error: 				//35h
		case LC786X_EC_MP3_FileFrameError: 			//45h 
		case LC786X_EC_USB_ErrUnexpected: 			//60h 
		case LC786X_EC_USB_EnumerateError: 			//62h
		case LC786X_EC_USB_ErrResponse: 			//63h
		case LC786X_EC_FileSysInitializeError: 		//68h
		case LC786X_EC_FileSysUnknown: 				//69h 
		case LC786X_EC_FileSysAnalyze: 				//6Ah 
			DISP_ErrorCode_ErrXX();
		break;	
		case LC786X_EC_DecodeError: //41h 
		case LC786X_EC_WMA_DecodeError: //48h 
		case LC786X_EC_AAC_DecodeError: //4Ah 
			DISP_ErrorCode_DecError();
			break;
		case LC786X_EC_MP3_FileFrameReadError: //44h 
			DISP_ErrorCode_FrameError();
			break;
		case LC786X_EC_MP3_FileSizeError: //46h	
		case LC786X_EC_WMA_FileSizeError: //47h
		case LC786X_EC_AAC_FileSizeError: //49h 
			DISP_ErrorCode_SizeError();
			break;
		case LC786X_EC_WMA_CopyrightedFile: //51h 
		case LC786X_EC_AAC_CopyrightedFile: //52h  
			DISP_ErrorCode_DrmError();
			break;
		case LC786X_EC_USB_ErrDriver: //61h 
			DISP_ErrorCode_UsbError();
			break;
		case LC786X_EC_FileOpenError: //6Bh	
		case LC786X_EC_FileReadError: //6Ch	
			DISP_EC_OpenError();
			break;			
	}
}

unsigned char DISP_Temp_PowerOff(void)
{
	unsigned char ucRet = 1;
	
#ifdef  OPTIONAL_CLOCK
	if  (OPT_GetOption(OPT_MASK_CLOCK) == 0)
	{
		if (FUNC_PowerStatus() == 0)
		{
			return(0);
		}
	}
#endif

	switch  (ucDISP_TempDispMode)
	{
		case DISP_NO_MECH:	
		case DISP_NO_USB:
		case DISP_NO_AUX:
		#ifdef CD
		case DISP_NO_CD:
		#endif	
			if	(ucDISP_Blink == 0)
			{
				DISP_TempString(ucDISP_TempDispMode);
			}	
			break;
	#ifdef  BLUETOOTH
		case DISP_BT_CALL_MISS:
			if  (OPT_GetOption(OPT_MASK_CLOCK))
			{
				DISP_BT_Temp_CallMiss();
			}
			break;
		case DISP_BT_CALL_REJECT:
			if  (OPT_GetOption(OPT_MASK_CLOCK))
			{
				DISP_BT_Temp_CallReject();
			}
			break;
		case DISP_BT_CALL_END:
			if  (OPT_GetOption(OPT_MASK_CLOCK))
			{
				DISP_BT_Temp_CallEnd();
			}
			break;
		case DISP_BT_RECENT_CALLS:
			DISP_BT_Temp_RecentCall();
			break;
	#endif		
		default:
			ucRet = 0;
			break;
	}

	return(ucRet);
}

unsigned char DISP_Temp_PowerOn(void)
{
	unsigned char ucRet = 1;
	
	switch  (ucDISP_TempDispMode)
	{
		case DISP_NO_MECH:
		case DISP_NO_USB:
		case DISP_NO_AUX:
		#ifdef CD
		case DISP_NO_CD:
		#endif	
			if	(ucDISP_Blink == 0)
			{	
				DISP_TempString(ucDISP_TempDispMode);
			}
			break;
		#ifdef CD
		case DISP_EJECT:
			DISP_TEMP_CD_Eject();
			break;
		#endif	
		case DISP_VOLUME:
			DISP_Volume();			
			break;
	#ifdef  AUTO_GUIDE
		case DISP_AG_VOLUME:
			AG_DISP_Volume();
			break;
	#endif
		case DISP_USB_DEVICE_ERROR:
			DISP_ErrorCode_UsbError();
			break;
		case DISP_NO_FILE:
			DISP_ErrorCode_NoFile();
			break;
	#ifdef  CD
		case DISP_CD_ERROR:
			DISP_CD_ErrorCode_Err00();
			break;
	#endif
		case DISP_USB_ERROR:
			DISP_USB_ErrorCode_Err00();
			break;
	#ifdef  AV_CONTROLLER
		case DISP_DRV_ON:
			DISP_Temp_AVC_DrvOn();
			break;
		case DISP_DRV_OFF:
			DISP_Temp_AVC_DrvOff();
			break;
		case DISP_SP_ON:
			DISP_Temp_SP_On();
			break;
		case DISP_SP_OFF:
			DISP_Temp_SP_Off();
			break;
		case DISP_AVC_MIC_OFF:
			DISP_Temp_MIC_Off();
			break;
		case DISP_AVC_MIC_ON:
			DISP_Temp_MIC_On();
			break;
		case DISP_AVC_MIX_OFF:
			DISP_Temp_MIX_Off();
			break;
		case DISP_AVC_MIX_ON:
			DISP_Temp_MIX_On();
			break;
	#endif
		case DISP_NO_INFO:
			DISP_No_Info();
	#ifdef  ST_EV_ADJ
		case DISP_ST_EV:
			DISP_ST_EV_Adjust();
			break;
	#endif
		case DISP_FIRMWARE_HOST:
	#ifdef  BLUETOOTH
		case DISP_FIRMWARE_BLUETOOTH:
	#endif
		case DISP_FIRMWARE_USB:
			DISP_Temp_FirmwareUpdate(ucDISP_TempDispMode);
			break;
		case DISP_EQ_FLAT:
			DISP_Temp_EQFlat(ucDISP_TempDispMode);
			break;
		case DISP_TUNER_SEEK_TEST:
			DISP_Temp_TunerSeekTest();
			break;
		case DISP_TUNER_INFO:
			DISP_Temp_TunerInfo();
			break;
		case DISP_TUNER_PRESET_CLEAR:
			DISP_Temp_TunerPresetClear();
			break;
		case DISP_LOCAL_NORTH_AMERICA:
			DISP_Temp_Local_NorthAmerica();
			break;
		case DISP_LOCAL_SOUTH_AMERICA:
			DISP_Temp_Local_SouthAmerica();
			break;
		case DISP_LOCAL_ASIA:
			DISP_Temp_Local_Asia();
			break;
		case DISP_LOCAL_EUROPE:
			DISP_Temp_Local_Europe();
			break;
		case DISP_NoUSB:
			DISP_Temp_NoUSB();
			break;
		case DISP_NoFile:
			DISP_Temp_NoFile();
			break;
		case DISP_USBCheck:
			DISP_Temp_USBCheck();
			break;
	#ifdef  FILE_SEARCH
		case DISP_FILE_SEARCH:
			DISP_Temp_FileSearch();
			break;
	#endif
		case DISP_FirmwereUpdateError:
			DISP_Temp_FirmwereUpdateError();
			break;
		case DISP_FirmwereUpdateFail:
			DISP_Temp_FirmwereUpdateFail();
			break;
	#ifdef  DRV_SPK
		case DISP_DRIVER_SPEAKER:
			DISP_Temp_DriverSpeaker();
			break;
	#endif
	#ifdef BLUETOOTH
		case DISP_BT_TEST:
			DISP_BT_Temp_BluetoothTest();
			break;
		case DISP_BT_ADD1:
			DISP_BT_Temp_BluetoothADD1();
			break;
		case DISP_BT_ADD2:
			DISP_BT_Temp_BluetoothADD2();
			break;
		case DISP_BT_MIC:
			DISP_BT_Temp_BluetoothMIC();
			break;
		case DISP_BT_DUT:
			DISP_BT_Temp_BluetoothDUT();
			break;
		case DISP_BT_VOLUME:
			DISP_BT_Temp_Volume();
			break;
		case DISP_BT_CONNECT:
			DISP_BT_Temp_Connect();
			break;
		case DISP_BT_CONNECT_DEVICE_NAME:
			DISP_BT_Temp_ConncetDeviceName();
			break;
		case DISP_BT_NOCONNECT:
			DISP_BT_Temp_Noconncet();
			break;
		case DISP_BT_ICON_DEVICENAME:
			DISP_TEMP_BT_Icon_DeviceName();
			break;
		case DISP_BT_PAIR_NO_DEVICE:
			DISP_BT_Temp_PairNoDevice();
			break; 	
		case DISP_BT_PAIR_CANCEL:
			DISP_BT_Temp_PairCancel();
			break;
		case DISP_BT_NOLIST:
			DISP_BT_Temp_NoList();
			break;
		case DISP_BT_LIST_FULL:
			DISP_BT_Temp_ListFull();
			break;
		case DISP_BT_MODE_SET:
			DISP_BT_Temp_ModeSet();
			break;
		case DISP_BT_CALL_IN:
			DISP_BT_Temp_CallIn();
			break;
		case DISP_BT_ACCPET_CALL:
			DISP_BT_Temp_AcceptCall();
			break;
		case DISP_BT_CALL_MISS:
			DISP_BT_Temp_CallMiss();
			break;
		case DISP_BT_CALL_REJECT:
			DISP_BT_Temp_CallReject();
			break;
		case DISP_BT_CALL_END:
			DISP_BT_Temp_CallEnd();
			break;
		case DISP_BT_RECENT_CALLS:
			DISP_BT_Temp_RecentCall();
			break;
		case DISP_BT_REDIAL:
			DISP_BT_Temp_Redial();
			break;
		case DISP_BT_FWD:
			DISP_BT_Temp_Forward();
			break;
		case DISP_BT_RWD:
			DISP_BT_Temp_Rewind();
			break;
		case DISP_BT_MICVOLUME:
			DISP_BT_Temp_MIC_Volume();
			break;
		case DISP_BT_PHONEBOOK_DOWNLOAD_START:
			DISP_BT_PhonebookDownloadStart();
			break;
		case DISP_BT_PHONEBOOK_DOWNLOAD_END:
			DISP_BT_PhonebookDownloadEnd();
			break;
		case DISP_BT_PHONEBOOK_DELETE:
			DISP_BT_PhonebookDelete();
			break;
	#endif		
		default:
			ucRet = 0;
			break;
	}

	return(ucRet);
}

void DISP_BlinkFlag(void)
{
	if  (ucDISP_Blink_Timer50msec == 0)
	{
		ucDISP_Blink_Timer50msec = 500/50;
		if  (ucDISP_Blink == 0)
		{
			ucDISP_Blink = 1;
		}
		else
		{
			ucDISP_Blink = 0;
		}

		if  (ucDISP_TempPage < 30)
		{
			++ucDISP_TempPage;
		}
	}
}

#ifdef  USB_DISABLE_TEST
extern unsigned char ucDisable_USB;
#endif

void DISP_IconMain(void)
{
	unsigned char ucFunc = FUNC_GetCurrentFunction();

	if  (ucAUDIO_Equalizer != EQ_OFF)
	{
		DISP_IconSetStatusFlag(1, ICON_MASK_EQ);			
	}
	if	(ucAUDIO_Loud != 0)
	{
		DISP_IconSetStatusFlag(1, ICON_MASK_LOUD);
	}

	if (ucLC786XXX_USB_Detected == 1)
	{
		DISP_IconSetStatusFlag(1, ICON_MASK_USB);
	}
	
#ifdef  USB_DISABLE_TEST
	if  (ucDisable_USB == 1)
	{
		if  (ucDISP_Blink == 0)
		{
			DISP_IconSetStatusFlag(1, ICON_MASK_USB);
		}
	}
#endif

//	if  (ucAUX_Detected == 1)
//	{
//		DISP_IconSetStatusFlag(ICON_MASK_AUX, 0);
//	}

	if  (OPT_GetOption(OPT_MASK_AVC) == 0)
	{
		switch  (AUDIO_GetSpeakerMode())
		{
			case DSPK_ALL:
				DISP_IconSetStatusFlag(1, ICON_MASK_ALL);
				break;
			case DSPK_DRIVER:
				DISP_IconSetStatusFlag(1, ICON_MASK_DRV);
				break;
			case DSPK_PSG:
				DISP_IconSetStatusFlag(1, ICON_MASK_PSG);
				break;
		}
	}

#ifdef BLUETOOTH
//	if  (ucBT_On == 1)
	{
		if	(BT_ConnectStatus() == 1)
		{
			DISP_IconSetStatusFlag(1, ICON_MASK_BT);
		}	
		else
		{
			if  (BT_CurrentProcess_Connect() == 1)
			{
				if  (ucDISP_Blink == 0)
				{
					DISP_IconSetStatusFlag(1, ICON_MASK_BT);
				}
			}
		}			
	}
#endif
	
#ifdef CD
	if  (ucDECK_Disc == 1)
	{
		DISP_IconSetStatusFlag(1, ICON_MASK_CDDET_ALL);
	}	

	if	(ucFunc == FUNC_CD)
	{	
		switch  (ucDISP_CD_ICON_Step)
		{
			case  0:
				DISP_IconSetStatusFlag(0, ICON_MASK_CDDET_X1);
				break;
			case 1:
				DISP_IconSetStatusFlag(0, ICON_MASK_CDDET_X2);
				break;
			case 2:
				DISP_IconSetStatusFlag(0, ICON_MASK_CDDET_X3);
				break;
			case 3:
				DISP_IconSetStatusFlag(0, ICON_MASK_CDDET_X4);
				break;
			case 4:
				DISP_IconSetStatusFlag(0, ICON_MASK_CDDET_X5);
				break;
			case 5:
				DISP_IconSetStatusFlag(0, ICON_MASK_CDDET_X6);
				break;
			case 6:	
				DISP_IconSetStatusFlag(0, ICON_MASK_CDDET_X7);
				break;
			case 7:
				DISP_IconSetStatusFlag(0, ICON_MASK_CDDET_X8);
				break;
			
		}
		
		if  (ucDISP_CD_ICON_Timer5msec == 0)
		{
			ucDISP_CD_ICON_Timer5msec = 150/5;//150/5;

			if	(++ucDISP_CD_ICON_Step > ICON_CDDET_MAX)
			{
				ucDISP_CD_ICON_Step = ICON_CDDET_START;
			}
		}		
	}	
	#endif

	switch	(ucFunc)
	{
		case FUNC_TUNER:
			TUNER_DISP_IconMain();
			break;
		case FUNC_USB:
			USB_DISP_IconMain();
			break;		
	#ifdef  CD
		case FUNC_CD:
			CD_DISP_IconMain();		
			break;
	#endif
		case FUNC_AUX:
			AUX_DISP_IconMain();
			break;
	#ifdef  BLUETOOTH
		case FUNC_A2DP:
			BTA_DISP_IconMain();
			break;
		case FUNC_HF:
			Bluetooth_DISP_IconMain();
			break;
	#endif
	#ifdef  AV_CONTROLLER
		case FUNC_AVC_MODE:
			AVC_MODE_DISP_IconMain();
			break;
	#endif
	}

}
 
void DISP_SubText(void)
{
	if	(FUNC_PowerStatus() == 0)
	{
		DISP_SubText_PowerOff();
	}
	else
	{	
		DISP_SubText_PowerOn();
	}	
}

void DISP_MainText_PowerOn(void)
{
	unsigned char ucFunc = FUNC_GetCurrentFunction();

	if  ((ucDISP_ClockMode == 1) && (ucDISP_CurrentDisplay_Timer50msec == 0))
	{
		switch  (ucFunc)
		{
			case FUNC_TUNER:
				if  (TUNER_SoundStatus() == 1)
				{
					DISP_MainText_Clock();
					return;
				}
				break;
		#ifdef  CD
			case FUNC_CD:
				if  (CD_SoundStatus() == 0)
				{
					break;
				}
				if  ((ucDISP_FileName == 0) && (ucDISP_FolderName == 0))
				{
					DISP_MainText_Clock();
					return;
				}
				break;
		#endif
			case FUNC_USB:
				if  (USB_SoundStatus() == 0)
				{
					break;
				}
				if  ((ucDISP_FileName == 0) && (ucDISP_FolderName == 0))
				{
					DISP_MainText_Clock();
					return;
				}
				break;
			default:
				DISP_MainText_Clock();
				return;
		}
	}

#ifdef  PHONE_BOOK
	if  ((ucMV_PBAP_Status == MV_PBAP_DOWNLOADING) && (ucPBAP_CurrentContents == PBAP_CONTENTS_PHONEBOOK))
	{
		if  (ucDISP_CurrentDisplay_Timer50msec == 0)
		{
			DISP_BT_PhonebookDownloadStart();
			return;
		}
	}
	if  (ucBT_Process == BT_PRS_PAIRING)
	{
		if  (ucDISP_CurrentDisplay_Timer50msec == 0)
		{
			UI_DMENU_Bluetooth_PairActive();
			return;
		}
	}
#endif

#ifdef  AUTO_GUIDE
	if  (AG_GetAnnounceStatus() == AG_ANNOUNCE_ON)
	{
		AG_DISP_MainText();
		return;
	}
#endif

	switch  (ucFunc)
	{
		case FUNC_TUNER:
			TUNER_DISP_MainText();
			break;
		case FUNC_USB:
			USB_DISP_MainText();
			break;
		case FUNC_AUX:
			AUX_DISP_MainText();
			break;
	#ifdef  CD
		case FUNC_CD:
			CD_DISP_MainText();
			break;
	#endif
	#ifdef  BLUETOOTH
		case FUNC_A2DP:
			BTA_DISP_MainText();
			break;
		case FUNC_LPB:
			BT_LPB_DISP_MainText();
			break;
		case FUNC_HF:
			BTH_DISP_MainText();
			break;
	#endif
	#ifdef  AV_CONTROLLER
		case FUNC_AVC_MODE:
			AVC_MODE_DISP_MainText();
			break;
	#endif
	}
}
void DISP_LC786XXX_FirmwareUpdate(void)
{
	switch  (ucLC786XXX_UpdateStatus)
	{
		case LC786X_MS_UPDATE_PREPARATION_ONGOING:
			DISP_Temp_USBCheck();
			break;
		case LC786X_MS_WAITING_UPFATE:
			break;
		case LC786X_MS_EXECUTION_START:
			DISP_Temp_FirmwereUpdateStart();
			break;
		case LC786X_MS_VBUS_CUT_REQUEST:
		#ifdef  MODEL_ARA5040
			DISP_Temp_FirmwereUpdateStart();
		#endif
			break;
		case LC786X_MS_EXECUTION_ONGOING:
			if  (ucLC786XXX_UpdatePersent < 0x64)
			{
				DISP_LC786X_FirmwereUpdatePercent(ucLC786XXX_UpdatePersent);
			}
			break;
		case LC786X_MS_FINISH_NORMAL:
			DISP_Temp_FirmwereUpdateComplete();
			break;
	}
}

void DISP_MainText(void)
{		
	if  (FUNC_PowerStatus() == 0)
	{
		if  (DISP_Temp_PowerOff() == 1)
		{
			return;
		}
		if  (MENU_DISP_Main() == 1)
		{
			return;
		}
		DISP_MainText_PowerOff();
	}
	else
	{
		if  (DRV_LC786XXX_FirmwareUpdate_ON == 1)
		{
			DISP_LC786XXX_FirmwareUpdate();
			return;
		}
		if  (ucDISP_RadioInfo_Active != 0)
		{
			DISP_Temp_TunerInfo();
			return;
		}
		if  (DISP_Temp_PowerOn() == 1)
		{
			return;
		}
		if  (MENU_DISP_Main() == 1)
		{
			return;
		}
		if	((ucAUDIO_Mute == 1) || (ucAUDIO_TelMute == 1))
		{
			DISP_Display_Mute();
		}
		else if  (ucDISP_TempDispMode == DISP_NONE)
		{
			DISP_MainText_PowerOn();
		}
	}
}

void DISP_Main(void)
{
	DISP_BlinkFlag();
	
	if  (usDISP_TempDispMode_Timer50msec == 0)
	{
		if  (ucDISP_TempDispMode == DISP_FILE_SEARCH)
		{
		}
		else
		{
			ucDISP_TempDispMode = DISP_NONE;
		}
	}

#ifdef  MOVON
	if  (ucMV_HF_AudioStatus_Timer50msec != 0)
	{
		return;
	}
#endif

#ifdef  MODEL_ARA5040
	memset(&ucDISP_Buf[0], 0x00, sizeof(ucDISP_Buf));	
#else
	ST7565_DisplayClear();
#endif

	#ifdef	ZYLE_LOGO
	if  (OPT_GetOption(OPT_MASK_LOGO))
	{
		if  (ucDISP_LogoActive == 1)
		{
			DISP_ZyleDaewoo();
			if  (ucDISP_LogoActive_Timer100msec == 0)
			{
				ucDISP_LogoActive = 0;
				
				if  ((OPT_GetOption(OPT_MASK_CLOCK) == 0) && (FUNC_PowerStatus() == 0))
				{
					PWR_DisplayDriverOff();
					PWR_PowerControl(PWR_BACKLIGHT, 0);
				}
			}
			return;
		}
	}
	#endif
	DISP_IconClearStatusFlag();

	DISP_MainText();

	DISP_SubText();
	
	if	(FUNC_PowerStatus() == 1)
	{
		DISP_IconMain();
	}	
#ifdef  ST7565P
	ST7565_UpdateIconData(ulDISP_IconBuf);
#endif
	
#ifdef  PT6524
	PT6524_MakeDriverData(&ucDISP_Buf[0], &ulDISP_IconBuf);
#endif

}

